﻿/*
 * Created by SharpDevelop.
 * User: Masy Freddy
 * Date: 15/09/2011
 * Time: 17:31
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;

using MetaVideoEditorEvolved.Helper;

namespace ProviderTheTVDB
{
	/// <summary>
	/// Interaction logic for Option.xaml
	/// </summary>
	public partial class Option : Window
	{
		ConfigurationAddIn configurationAddIn;
		
		public Option(ConfigurationAddIn configurationAddIn)
		{
			this.configurationAddIn = configurationAddIn;
			
			InitializeComponent();
			
			comboBoxTraceLevel.ItemsSource =  TracerLevel.GetNames(typeof(TracerLevel)).ToList();
			
			if(this.configurationAddIn != null)
			{
				comboBoxLanguage.Text = this.configurationAddIn.Language;
				comboBoxTraceLevel.Text = this.configurationAddIn.TraceLevel;
				comboBoxSecondLanguage.SelectedIndex = (int)this.configurationAddIn.SecondLanguage;
			}
		}
		
		void buttonSave_Click(object sender, RoutedEventArgs e)
		{
			if(configurationAddIn == null)
			{
				configurationAddIn = new ConfigurationAddIn();
			}
			
			configurationAddIn.TraceLevel = comboBoxTraceLevel.Text;
			configurationAddIn.Language = comboBoxLanguage.Text;
			configurationAddIn.SecondLanguage = (LanguageName)comboBoxSecondLanguage.SelectedIndex;
			ConfigurationManager.Serialize(configurationAddIn);
			
			this.Close();
		}
		
		void buttonCancel_Click(object sender, RoutedEventArgs e)
		{
			this.Close();
		}
	}
}